﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using King.Engine.Core;
using King.Engine.GameObjects.Hud.Menu;
using Microsoft.Xna.Framework;

namespace King.Engine.Tester
{
    public class MenuActivity : Activity
    {

        #region Fields

        private Menu _menu;

        #endregion


        #region Constants

        private static readonly string[] PlayerSpeeds = new string[] { "1", "2", "3", "4", "5" };
        private static readonly string[] YesNo = new string[] { "Yes", "No" };

        #endregion


        #region Protected Methods

        protected override void OnStart()
        {

            MenuTree tree = new MenuTree("Main Menu")
            {
                {"Play", Play},
                {new MenuTree("Options")
                {
                    {"Player Speed", PlayerSpeeds, PlayerSpeedChanged, Player.Speed -1},
                    {"Show Player Label", YesNo, ShowPlayerLabelChanged}
                }},
                {"Quit", Quit}
            };

            MenuLayout layout = new MenuLayout()
            {
                TitleColor = Color.Red,
                ItemColor = Color.White,
                SelectedItemColor = Color.Yellow,
                TitleLocation = new Vector2(10, 10),
                FirstItemLocation = new Vector2(50, 40),
                ItemSeparation = new Vector2(0, 20)
            };

            _menu = new Menu(tree, .5f, "Label", layout);

            AddGameObject(_menu);
        }

        protected override void OnResume()
        {

        }

        #endregion


        #region 

        private void Play()
        {
            ActivityManager.SetActivity<GameActivity>();
        }

        private void Quit()
        {
            Engine.Core.Game.ExitGame();
        }

        private void PlayerSpeedChanged(string newSpeed)
        {
            Player.Speed = int.Parse(newSpeed);
        }

        private void ShowPlayerLabelChanged(string showLabel)
        {
            Player.ShowLabel = (showLabel == "Yes");
        }

        #endregion

    }
}
